package threadlocal_test;

import org.apache.commons.collections4.map.HashedMap;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author Ajie
 * @date 2023/3/25
 * @function
 * ConcurrentHashMap 不能put null
 * ConcurrentHashMap 不能remove null
 *
 * 可以 put 、remove null.
 * HashedMap   org.apache.commons.collections4.map.HashedMap
 * HashedMap   java.util.HashMap
 */
public class ConcurrentHashMapDemo {

    public static void main(String[] args) {
//        Map<Object,Object> hashMap = new HashedMap<>();
        Map<Object,Object> hashMap = new HashMap<>();
        hashMap.put(null,null);
        System.out.println("ConcurrentHashMapDemo:main: map can put null:"+hashMap.size());
        hashMap.remove(null);
        System.out.println("ConcurrentHashMapDemo:main: map remove null:"+hashMap.size());

        Map<Integer,Integer> map = new ConcurrentHashMap<>();
//        map.remove(null);//NullPointerException

        map.put(null,1);
        System.out.println("ConcurrentHashMapDemo:main:over");
    }
}
